clear all

use "metadata.dta"

set obs 10

*diff between post and pre
metareg prediff if study<7, wsse(prediffse) random


*diff between post and pre - excluding study 3
metareg prediff if study!=3, wsse(prediffse)

*effect in post
metareg post, wsse(postse)


*diff between post and quasi
metareg qdiff, wsse(qdiffse)

*effect in pre
metareg pre, wsse(prese)



* creating figure 2
metareg prediff if study<7, wsse(prediffse) random
replace prediff=_b[_cons] in 7
replace prediffse=_se[_cons] in 7
replace study=7 in 7

metareg qdiff if study<7, wsse(qdiffse)
replace qdiff=_b[_cons] in 7
replace qdiffse=_se[_cons] in 7
replace study=7 in 7

gen lo = prediff-prediffse*1.96
gen hi = prediff+prediffse*1.96

twoway (scatter study prediff) (rcap hi lo study, ///
	horiz xlab(-.2(.1).2) xline(0) legend(off) ytitle("") subtitle("Prepost", margin(b=2)) ///
	xtitle("Difference in Effects (Prepost - Posttest)") xsc(titlegap(2)) ///
	ylab(7 `""Meta-Analytic" "Effect""' 6 "6 - GMOs" 5 "5 - Rx Drugs" 4 "4 - Estate Tax" 3 "3 - Education" 2 "2 - Foreign Aid" 1 "1 - Welfare") ///
	plotregion(margin(1 1 4 1)) graphregion(margin(0 2 0 0)) saving(meta_pre.gph, replace))
	
gen qlo = qdiff-prediffse*1.96
gen qhi = qdiff+prediffse*1.96

twoway (scatter study qdiff) (rcap qhi qlo study, ///
	horiz xlab(-.3(.1).2) xline(0) legend(off) ytitle("") subtitle("Quasi", margin(b=2)) ///
	xtitle("Difference in Effects (Quasi - Posttest)") xsc(titlegap(2)) ///
	ylab(7 `""Meta-Analytic" "Effect""' 6 "6 - GMOs" 5 "5 - Rx Drugs" 4 "4 - Estate Tax" 3 "3 - Education" 2 "2 - Foreign Aid" 1 "1 - Welfare") ///
	plotregion(margin(1 1 4 1)) graphregion(margin(0 2 0 0)) saving(meta_q.gph, replace))

	
graph combine meta_pre.gph meta_q.gph
